home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 7 / Amiga Format AFCD07 (Dec 1996, Issue 91).iso / serious / shareware / programming / aros / dos / finddosentry.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-09-12  |  2.5 KB  |  99 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: finddosentry.c,v 1.4 1996/09/11 12:58:46 digulla Exp $
  4.     $Log: finddosentry.c,v $
  5.     Revision 1.4  1996/09/11 12:58:46  digulla
  6.     Determine the size of the name (M. Fleischer)
  7.  
  8.     Revision 1.3  1996/08/13 13:52:46  digulla
  9.     Replaced <dos/dosextens.h> by "dos_intern.h" or added "dos_intern.h"
  10.     Replaced __AROS_LA by __AROS_LHA
  11.  
  12.     Revision 1.2  1996/08/01 17:40:51  digulla
  13.     Added standard header for all files
  14.  
  15.     Desc:
  16.     Lang: english
  17. */
  18. #include <dos/dosextens.h>
  19. #include <clib/utility_protos.h>
  20. #include "dos_intern.h"
  21.  
  22. /*****************************************************************************
  23.  
  24.     NAME */
  25.     #include <clib/dos_protos.h>
  26.  
  27.     __AROS_LH3(struct DosList *, FindDosEntry,
  28.  
  29. /*  SYNOPSIS */
  30.     __AROS_LHA(struct DosList *, dlist, D1),
  31.     __AROS_LHA(STRPTR,           name,  D2),
  32.     __AROS_LHA(ULONG,            flags, D3),
  33.  
  34. /*  LOCATION */
  35.     struct DosLibrary *, DOSBase, 114, Dos)
  36.  
  37. /*  FUNCTION
  38.     Looks for the next dos list entry with the right name. The list
  39.     must be locked for this. There may be not more than one device
  40.     or assign node of the same name. There are no restrictions on
  41.     volume nodes.
  42.  
  43.     INPUTS
  44.     dlist - the value given by LockDosList() or the last call to
  45.             FindDosEntry().
  46.     name  - logical device name without colon. Case insensitive.
  47.     flags - the same flags as given to LockDosList() or a subset
  48.             of them.
  49.  
  50.     RESULT
  51.     Pointer to dos list entry found or NULL if the are no more entries.
  52.  
  53.     NOTES
  54.  
  55.     EXAMPLE
  56.  
  57.     BUGS
  58.  
  59.     SEE ALSO
  60.  
  61.     INTERNALS
  62.  
  63.     HISTORY
  64.     29-10-95    digulla automatically created from
  65.                 dos_lib.fd and clib/dos_protos.h
  66.  
  67. *****************************************************************************/
  68. {
  69.     __AROS_FUNC_INIT
  70.     __AROS_BASE_EXT_DECL(struct DosLibrary *,DOSBase)
  71.     
  72.     static const ULONG flagarray[]=
  73.     { LDF_DEVICES, LDF_ASSIGNS, LDF_VOLUMES, LDF_ASSIGNS, LDF_ASSIGNS };
  74.     
  75.     /* Determine the size of the name (-1 if the last character is a ':') */
  76.     STRPTR end=name;
  77.     ULONG size;
  78.     while(*end++)
  79.         ;
  80.     size=~(name-end);
  81.     if(size&&*--end==':')
  82.         size--;
  83.  
  84.     /* Follow the list */   
  85.     for(;;)
  86.     {
  87.         /* Get next entry. Return NULL if there is none. */
  88.     dlist=dlist->dol_Next;
  89.     if(dlist==NULL)
  90.         return NULL;
  91.  
  92.     /* Check type and name */
  93.     if(flags&flagarray[dlist->dol_Type]&&
  94.        !Strnicmp(name,dlist->dol_Name,size)&&!dlist->dol_Name[size])
  95.         return dlist;
  96.     }
  97.     __AROS_FUNC_EXIT
  98. } /* FindDosEntry */
  99.